// logger
const logger = async (ctx, next) => {
  const start = Date.now(); // 记录请求开始时间
  const clientIp = ctx.request.ip; // 获取客户端 IP
  await next(); // 执行后续中间件
  const duration = Date.now() - start; // 计算请求处理时间
  console.log(
    `${clientIp}: ${ctx.method} ${ctx.url} - ${ctx.status} - ${duration}ms`,
  );
};

module.exports = logger;
